<p>This rule flags when <code>Array.findIndex()</code> or <code>Array.findLastIndex()</code> is used with a simple equality comparison that could be
replaced with the more direct <code>indexOf()</code> or <code>lastIndexOf()</code> methods.</p>
<h2>Why is this an issue?</h2>
<p>The <code>findIndex()</code> and <code>findLastIndex()</code> methods are designed for complex search operations that require custom logic. When
you only need to find the index of a specific value using strict equality comparison, these methods are unnecessarily complex.</p>
<p>Using <code>indexOf()</code> and <code>lastIndexOf()</code> for simple equality searches offers several advantages:</p>
<ul>
  <li> <strong>Better performance</strong>: These methods are optimized for equality comparisons and don’t require function call overhead </li>
  <li> <strong>Clearer intent</strong>: The code directly expresses that you’re looking for a specific value </li>
  <li> <strong>Simpler syntax</strong>: No callback function is needed, reducing code complexity </li>
  <li> <strong>Better readability</strong>: Other developers can immediately understand the search operation </li>
</ul>
<p>The <code>findIndex()</code> and <code>findLastIndex()</code> methods should be reserved for cases where you need custom comparison logic, use
additional callback parameters (like index or array), or perform complex operations during the search.</p>
<h3>What is the potential impact?</h3>
<p>Using <code>findIndex()</code> for simple equality searches creates unnecessary complexity and may impact performance. While the functional
difference is minimal, the code becomes harder to read and maintain. In performance-critical applications, the overhead of callback function execution
can accumulate over many operations.</p>
<h3>How to fix?</h3>
<p>Replace <code>findIndex()</code> with <code>indexOf()</code> when searching for a specific value using strict equality comparison.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const index = items.findIndex(x =&gt; x === 'target'); // Noncompliant
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const index = items.indexOf('target');
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-array-index-of.md">prefer-array-index-of</a> </li>
  <li> MDN - Array.prototype.indexOf() - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf">Documentation for the indexOf() method</a>
  </li>
  <li> MDN - Array.prototype.lastIndexOf() - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf">Documentation for the lastIndexOf()
  method</a> </li>
  <li> MDN - Array.prototype.findIndex() - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex">Documentation for the findIndex() method</a>
  </li>
  <li> MDN - Array.prototype.findLastIndex() - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex">Documentation for the findLastIndex()
  method</a> </li>
</ul>
